﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.controllers {
    import flash.utils.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.world.vos.*;
    import __AS3__.vec.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.interfaces.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;
    import net.wooga.pets.models.world.*;

    public class CreateRewardIconsCommand extends Command {

        public var event:InfoEvent;
        public var world:WorldModel;
        public var userModel:UserModel;
        public var collectionModel:CollectableModel;

        override public function execute():void{
            var _local4:Object;
            var _local5:RewardItemVO;
            l(("execute: " + this.execute));
            if (this.userModel.isVisitFriendsMode()){
                return;
            };
            var _local1:Array = (this.event.info as Array);
            var _local2:Vector.<RewardItemVO> = new Vector.<RewardItemVO>();
            if (((_local1) && (_local1.length))){
                for each (_local4 in _local1) {
                    _local5 = new RewardItemVO();
                    _local5.id = ((_local4.id) || ((RewardItemVO.COLLECTION_ID + getTimer())));
                    _local5.itemType = _local4.item_type;
                    if (_local5.isCollectionItem){
                        _local5.petType = this.collectionModel.lastAddedPetType;
                        _local5.amount = "1";
                    } else {
                        _local5.amount = _local4.amount;
                    };
                    _local2.push(_local5);
                };
            };
            var _local3:IRoom = (this.world.getRoomById(this.event.id) as IRoom);
            _local3.rewardItems = _local2;
            dispatch(new InfoEvent(EventConstants.SHOW_REWARD_ICONS, this.event.id, true));
        }

    }
}//package net.wooga.pets.controllers 
